package com.ruoyi.product.controller;

import com.ruoyi.business.domain.product.TbProductSpecTemplates;
import com.ruoyi.business.service.product.TbProductSpecTemplatesService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 规格分类模板表Controller
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("/business/product/spec/templates")
@Api(tags = "规格分类模板管理接口")
public class TbProductSpecTemplatesController extends BaseController {

    private final TbProductSpecTemplatesService tbProductSpecTemplatesService;

    /**
     * 查询规格模板列表
     */
//    @SaCheckPermission("business:product:spectemplates:list")
    @GetMapping("/list")
    @ApiOperation("查询规格模板列表")
    public TableDataInfo<TbProductSpecTemplates> list(TbProductSpecTemplates tbProductSpecTemplates, PageQuery pageQuery) {
        return tbProductSpecTemplatesService.selectPageList(tbProductSpecTemplates,pageQuery);
    }
    @GetMapping(value = "/listAll")
    @ApiOperation("获取规格模板列表不分页")
    public R<List<TbProductSpecTemplates>> getInfo(TbProductSpecTemplates tbProductSpecTemplates) {
        return R.ok(tbProductSpecTemplatesService.selectSpecTemplatesList(tbProductSpecTemplates));
    }
    /**
     * 获取规格模板详细信息
     */
//    @SaCheckPermission("business:product:spectemplates:query")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取规格模板详情")
    public R<TbProductSpecTemplates> getInfo(@PathVariable("id") Long id) {
        return R.ok(tbProductSpecTemplatesService.selectSpecTemplatesById(id));
    }

    /**
     * 新增规格模板
     */
//    @SaCheckPermission("business:product:spectemplates:add")
    @PostMapping
    @ApiOperation("新增规格模板")
    public R<Boolean> add(@RequestBody TbProductSpecTemplates tbProductSpecTemplates) {
        return R.ok(tbProductSpecTemplatesService.insertSpecTemplates(tbProductSpecTemplates));
    }

    /**
     * 修改规格模板
     */
//    @SaCheckPermission("business:product:spectemplates:edit")
    @PutMapping
    @ApiOperation("修改规格模板")
    public R<Boolean> edit(@RequestBody TbProductSpecTemplates tbProductSpecTemplates) {
        return R.ok(tbProductSpecTemplatesService.updateSpecTemplates(tbProductSpecTemplates));
    }

    /**
     * 删除规格模板
     */
//    @SaCheckPermission("business:product:spectemplates:remove")
    @DeleteMapping("/{ids}")
    @ApiOperation("删除规格模板")
    public R<Boolean> remove(@PathVariable Long[] ids) {
        return R.ok(tbProductSpecTemplatesService.deleteSpecTemplatesByIds(ids));
    }
}
